package cn.xiaobai;

import cn.xiaobai.tools.Packager;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import java.util.function.Supplier;

/**
 * @Author yangdaji
 * @Date 2023/10/26
 * @PackageName cn.xiaobai
 * @ClassName AbstractRepackageMojo
 */
public abstract class AbstractRepackageMojo extends AbstractMojo {


    @Parameter
    private String mainClass;

    @Parameter
    private String startClass;

    @Parameter(defaultValue = "${project}", readonly = true, required = true)
    protected MavenProject project;


    protected <P extends Packager> P getConfiguredPackager(Supplier<P> supplier) {
        P packager = supplier.get();
        packager.setMainClass(this.mainClass);
        return packager;
    }

    protected Artifact getSourceArtifact(String classifier) {
        return this.project.getArtifact();
    }

}
